package com.eddie.libray.reception;

import com.eddie.libray.LibraryApp;
import com.eddie.libray.LibraryDataSource;
import com.eddie.libray.service.AdminService;

import java.text.SimpleDateFormat;
import java.util.Date;

import static com.eddie.libray.MenuConstant.ADMIN_MENU_RETURN;

/**
 * 管理员的请求接收器
 *
 * @author Eddie
 * @since 2022/09/02 09:09
 **/
public class AdminReception extends AbstractReception {

    private final AdminService adminService = new AdminService();

    public AdminReception(LibraryApp app) {
        super(app);
    }

    @Override
    public boolean action() {
        menu.adminMenu();
        String answer = scanner.next();
        switch (answer) {
            case "1": {
                adminService.list();
                break;
            }
            case "2": {
                adminService.add();
                break;
            }
            case "3": {
                adminService.update();
                break;
            }
            case "4": {
                adminService.delete();
                break;
            }
            case ADMIN_MENU_RETURN: {
                //管理员退出登陆后将图书馆程序设置为菜单接收器状态
                app.setReceptionState(app.getMainReception());
                return false;
            }
            default: {
                System.out.println("请正确选择！");
            }
        }
        return true;
    }

}
